<template>
  <u-container-layout>
    <zlrt-table :p="ctx">
      <template #before>
        <zlrt-search :p="ctx">
          <template #warehouseName>
            <el-select v-model="ctx.filter.warehouseId">
              <el-option
                v-for="item in warehouseOptions"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              >
              </el-option>
            </el-select>
          </template>
        </zlrt-search>
        <div class="tool-bar">
          <el-button
            type="danger"
            v-hasPermit="['wms-order:delivery:del']"
            icon="Delete"
            :disabled="!ctx.selected.length"
            @click="ctx.batchDelete()"
          >
            批量删除
          </el-button>
          <span style="float: right">
            <el-button
              type="success"
              v-hasPermit="['wms-order:delivery:list']"
              :loading="ctx.exportLoading"
              icon="Download"
              @click="ctx.export()"
            >
              导出
            </el-button>
            <!-- <el-button type="primary" v-hasPermit="['wms-order:delivery:save']" icon="Plus" @click="ctx.showEdit()">
              添加
            </el-button> -->
          </span>
        </div>
      </template>
      <template #status="scope">
        {{ ctx.other.getStatusName(scope.row.status) }}
      </template>
      <template #createOn="scope">
        {{ ctx.other.formatDt(scope.row.createOn) }}
      </template>
      <template #operation="scope">
        <el-button
          type="primary"
          v-hasPermit="['wms-order:delivery:save']"
          link
          size="small"
          icon="Edit"
          @click="ctx.showEdit(scope.row) && ctx.other.makeList(scope.row.id)"
        >
          明细
        </el-button>
        <el-button
          v-hasPermit="['wms-order:delivery:del']"
          type="danger"
          link
          size="small"
          icon="Delete"
          @click="ctx.del(scope.row.id)"
        >
          删除
        </el-button>
      </template>
      <template #after>
        <el-dialog
          v-model="ctx.editVisible"
          title="发货单明细"
          width="90%"
          top="3vh"
          append-to-body
          :close-on-click-modal="false"
          @close="ctx.closeEdit()"
        >
          <el-form
            :ref="(e) => (ctx.formRef = e)"
            :model="ctx.editData"
            :rules="ctx.rules"
            v-loading="ctx.editLoading"
            label-width="120px"
            class="demo-ruleForm"
          >
            <el-table
              :data="ctx.editData.orderGoodsList"
              style="width: 100%; margin-top: 10px"
            >
              <el-table-column prop="projectName" label="项目">
                <template #default="scope">
                  {{ scope.row.projectName || "-" }}
                </template>
              </el-table-column>
              <!-- <el-table-column prop="areaName" label="库区" />
                <el-table-column prop="locationName" label="库位名称" /> -->
              <!-- <el-table-column prop="locationCode" label="库位编码" /> -->
              <el-table-column prop="skuName" label="产品名称" width="300" />
              <el-table-column
                prop="serialNumber"
                label="出厂编号"
                width="150"
              />
              <el-table-column
                prop="specification"
                label="规格型号"
                width="200"
              >
                <template #default="scope">
                  {{ scope.row.specification || "-" }}
                </template>
              </el-table-column>
              <el-table-column prop="number" label="数量" width="90">
                <template #default="scope">
                  {{ scope.row.number || "-" }}
                </template>
              </el-table-column>
              <el-table-column prop="unit" label="单位" width="90">
                <template #default="scope">
                  {{ scope.row.unit || "-" }}
                </template>
              </el-table-column>
            </el-table>
          </el-form>
          <template #footer>
            <span class="dialog-footer">
              <!-- <el-button @click="ctx.editVisible = false">取消</el-button>
                <el-button type="primary" @click="ctx.save()">确定</el-button> -->
              <el-button
                type="primary"
                icon="Download"
                @click="ctx.other.makeExport()"
                >导出</el-button
              >
            </span>
          </template>
        </el-dialog>
      </template>
    </zlrt-table>
  </u-container-layout>
</template>

<script lang="ts" src="./deliveryApply" />

<style lang="scss" scoped></style>
